package com.zxb.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zxb.common.annotation.Log;
import com.zxb.common.core.controller.BaseController;
import com.zxb.common.core.domain.AjaxResult;
import com.zxb.common.enums.BusinessType;
import com.zxb.system.domain.Beehivedata;
import com.zxb.system.service.IBeehivedataService;
import com.zxb.common.utils.poi.ExcelUtil;
import com.zxb.common.core.page.TableDataInfo;

/**
 * 蜂箱数据Controller
 * 
 * @author zxb
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/system/beehivedata")
public class BeehivedataController extends BaseController
{
    @Autowired
    private IBeehivedataService beehivedataService;

    /**
     * 查询蜂箱数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:list')")
    @GetMapping("/list")
    public TableDataInfo list(Beehivedata beehivedata)
    {
        startPage();
        List<Beehivedata> list = beehivedataService.selectBeehivedataList(beehivedata);
        return getDataTable(list);
    }

    /**
     * 导出蜂箱数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:export')")
    @Log(title = "蜂箱数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Beehivedata beehivedata)
    {
        List<Beehivedata> list = beehivedataService.selectBeehivedataList(beehivedata);
        ExcelUtil<Beehivedata> util = new ExcelUtil<Beehivedata>(Beehivedata.class);
        util.exportExcel(response, list, "蜂箱数据数据");
    }

    /**
     * 获取蜂箱数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(beehivedataService.selectBeehivedataByDataId(dataId));
    }

    /**
     * 新增蜂箱数据
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:add')")
    @Log(title = "蜂箱数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Beehivedata beehivedata)
    {
        return toAjax(beehivedataService.insertBeehivedata(beehivedata));
    }

    /**
     * 修改蜂箱数据
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:edit')")
    @Log(title = "蜂箱数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Beehivedata beehivedata)
    {
        return toAjax(beehivedataService.updateBeehivedata(beehivedata));
    }

    /**
     * 删除蜂箱数据
     */
    @PreAuthorize("@ss.hasPermi('system:beehivedata:remove')")
    @Log(title = "蜂箱数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(beehivedataService.deleteBeehivedataByDataIds(dataIds));
    }
}
